package com.speed_run.service.thirdLogin;

import com.speed_run.global.BusinessException;
import org.apache.shiro.authc.*;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;


public class GeneralLoginService {

    public void userLogin(Subject subject, UsernamePasswordToken token){
        try {
            subject.login(token);
        } catch (UnknownAccountException e) {
            throw new BusinessException("账户不存在");
        } catch (IncorrectCredentialsException e) {
            throw new BusinessException("用户名或密码错误");
        } catch (LockedAccountException e) {
            throw new BusinessException("账户被锁定");
        } catch (AuthenticationException e){
            throw new BusinessException("登录失败");
        } catch (RuntimeException e){
            throw e;
        }
    }
}
